package com.wetool.wechat.feign;

import com.wetool.wechat.model.open.WechatAccessTokenResponse;
import com.wetool.wechat.model.open.WechatOpenUserInfo;
import com.wetool.wechat.model.open.WechatRefreshTokenResponse;
import feign.Param;
import feign.RequestLine;

/**
 * 微信开放平台接口
 */
public interface WechatOpenPlatformFeignClient {

    /**
     * 获取开放平台登录用户的access token
     */
    @RequestLine("GET /sns/oauth2/access_token?appid={appId}&secret={secret}&code={code}&grant_type={grantType}")
    WechatAccessTokenResponse accessToken(@Param("appId") String appId, @Param("secret") String secret, @Param("code") String code, @Param("grantType") String grantType);

    /**
     * 开放平台登录用户 刷新 access token
     */
    @RequestLine("GET /sns/oauth2/refresh_token?appid={appId}&grant_type={grantType}&refresh_token={refreshToken}")
    WechatRefreshTokenResponse refreshToken(@Param("appId") String appId, @Param("grantType") String grantType, @Param("refreshToken") String refreshToken);

    /**
     * 认证token
     */
    @RequestLine("GET /sns/auth?access_token={accessToken}&openid={openId}")
    Object authToken(@Param("accessToken") String accessToken, @Param("openId") String openId);

    /**
     * 查询用户信息
     */
    @RequestLine("GET /sns/userinfo?access_token={accessToken}&openid={openId}")
    WechatOpenUserInfo userInfo(@Param("accessToken") String accessToken, @Param("openId") String openId);

}
